/* eslint-disable no-console */
const fs = require('fs');
const HTMLtoDOCX = require('html-to-docx');
const pug = require('pug')

const filePath = './example.docx';
const template = fs.readFileSync('./example.pug', 'utf-8');

const htmlString = fs.readFileSync('./4.html', 'utf-8');

(async () => {
  const fileBuffer = await HTMLtoDOCX(htmlString, null, {
    font: '华文细黑',
    table: { row: { cantSplit: true } },
    footer: true,
    pageNumber: true,
  });

  fs.writeFile(filePath, fileBuffer, (error) => {
    if (error) {
      console.log('Docx file creation failed: ', error);
      return;
    }
    console.log('Docx file created successfully');
  });
})();